var content = require('../../../public/content');
var columns = require('./columns');
var template = require('template');

return extend(content, {
    target:'#balance',
    path:'/balance/',
    data:{
        title:'科目余额表',
        exportsUrl:'http://www.baidu.com',
        printUrl:'',
        istwo:true
    },
    template:{
        left:renders({
            <%include 'date'%>
            <span class="ui-checkradio ui-checkradio-switches e-mt5">
                <input type="checkbox" name="showTop" data-on="全部科目" data-off="一级科目" value="1">
            </span>
            <span class="ui-checkradio ui-checkradio-switches e-ml10 e-mt5 e-mr10">
                <input type="checkbox" name="showYear" data-on="本年累计" data-off="本年累计" value="1">
            </span>
        })
    },
    grid:{
        paging:{
            url:sourceHttp,
            isPage:false
        },
        columns:columns(),
        onRender:function(self){
            var that = this;
            if(!this.selectMode || !this.selectMode.prev().is(':visible')){
                var data = self.data;
                //模拟数据
                data.isAccount = 1;
                data.isCurray = 1;
                var html = template.render(this.template.mode, data);
                if(html){
                    this.selectMode = $(html).appendTo(this.header.find('.left'));
                    this.selectMode.imitSelect({
                        callback:function(me, item){
                            if(item){
                                that.renderCol()
                            }
                        }
                    });
                }
            }
        }
    },
    renderCol:function(){
        var data = this.getQuery();
        this.datagrid.option('columns', columns(data.mode, data.showYear))
    },
    initCheckradio:function(){
        var that = this;
        that.header.find(':checkbox').checkradio({
            callback:function(ele){
                if(ele.attr('name') === 'showYear'){
                    that.renderCol();
                }
                else{
                    that.query();
                }
            }
        });
    }
})